package com.java.module.fire.controller.api;

import com.java.common.lang.annotation.Log;
import com.java.common.lang.annotation.ValidateToken;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.domain.page.Page;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.DateUtils;
import com.java.common.utils.WebKit;
import com.java.module.fire.domain.Activity;
import com.java.module.fire.domain.Post;
import com.java.module.fire.service.IPostService;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import com.java.module.fire.service.IActivityService;

import java.util.List;

/**
 * 活动内容Controller
 * 
 * @author Administrator
 * @date 2025-02-10
 */
@RestController("ApiActivityController")
@RequestMapping("/fire/activity")
@ValidateToken(isValidate = false)
public class ActivityController {

    @Autowired
    IActivityService activityService;




    @Autowired
    IPostService postService;

    /**
     * 查询活动内容列表
     */
    @GetMapping("/list")
    public Page<Post> list(Post post) {
        WebKit.startPage();
        post.setSignUp(0L);
        post.setBreed(1);
        List<Post> list = postService.selectPostList(post);
        return WebKit.getPageData(() -> list);
    }


    /**
     * 查询可以报名的活动内容列表
     */
    @GetMapping("/bannerList")
    public List<Post> bannerList(Post post) {
        post.setSignUp(1L);
        post.setStatus(0L);
        post.setBreed(1);
        List<Post> list = postService.selectPostList(post);
        return list;
    }

    /**
     * 获取活动内容详细信息
     */
    @GetMapping(value = "/info/{id}")
    @ApiImplicitParam(name = "id", value = "活动id", dataTypeClass = Long.class, required = true)
    public Post getInfo(@PathVariable("id") Long id) {
        System.out.println("iiiiiiiiiiiii="+id);
        //判断当前用户是否报名，如果已经报名
        return postService.selectPostById(id);
    }


    /**
     * 新增活动内容
     */
    @PostMapping
    public AjaxResult add(@RequestBody Activity activity) {
        return WebKit.toAjax(activityService.insertActivity(activity));
    }

}